package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCFaultReportFaultType;
import com.shrct.businessprocess.customerservice.RCFaultReportServiceSummary;
import com.shrct.businessprocess.customerservice.RCFaultReportServiceType;
import com.shrct.businessprocess.customerservice.RCServiceContractDelegate;
import com.shrct.businessprocess.customerservice.RCServiceRecord;
import com.shrct.businessprocess.customerservice.RCServiceStatus;
import com.shrct.businessprocess.customerservice.impl.RCFaultReportFaultTypeImpl;
import com.shrct.businessprocess.customerservice.impl.RCFaultReportServiceSummaryImpl;
import com.shrct.businessprocess.customerservice.impl.RCFaultReportServiceTypeImpl;
import com.shrct.businessprocess.customerservice.impl.RCServiceContractDelegateImpl;
import com.shrct.businessprocess.customerservice.proxy.RCServiceRecordProxy;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import com.shrct.businessprocess.organization.impl.RCEnterpriseImpl;
import com.shrct.businessprocess.product.RCIdentifiablePhysicalProductEntry;
import com.shrct.businessprocess.product.impl.RCIdentifiablePhysicalProductEntryImpl;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Collection;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCSERVICERECORD_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcservicerecord")
public class RCServiceRecordImpl extends BaseModelObject implements RCServiceRecord {
  public RCServiceRecordImpl() {
    super();
  }
  
  private String sid;
  
  public String getSid() {
    return this.sid;
  }
  
  public RCServiceRecord setSid(final String sid) {
    this.sid = sid;
    return this;			
    
  }
  
  @JoinColumn(name = "customer_id")
  @ManyToOne(targetEntity = RCEnterpriseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEnterprise customer;
  
  public RCEnterprise getCustomer() {
    return this.customer;
  }
  
  public RCServiceRecord setCustomer(final RCEnterprise customer) {
    this.customer = customer;
    return this;			
    
  }
  
  private String contractor;
  
  public String getContractor() {
    return this.contractor;
  }
  
  public RCServiceRecord setContractor(final String contractor) {
    this.contractor = contractor;
    return this;			
    
  }
  
  private String contractorPhone;
  
  public String getContractorPhone() {
    return this.contractorPhone;
  }
  
  public RCServiceRecord setContractorPhone(final String contractorPhone) {
    this.contractorPhone = contractorPhone;
    return this;			
    
  }
  
  private String location;
  
  public String getLocation() {
    return this.location;
  }
  
  public RCServiceRecord setLocation(final String location) {
    this.location = location;
    return this;			
    
  }
  
  @ManyToMany(targetEntity = RCEmployeeImpl.class)
  @JoinTable(name = "m2m_rcservicerecord_workers", joinColumns = @JoinColumn(name = "rcservicerecord_id") , inverseJoinColumns = @JoinColumn(name = "rCEmployee_inv_id") )
  private Collection<RCEmployee> workers = new java.util.ArrayList<com.shrct.businessprocess.organization.RCEmployee>();;
  
  public Collection<RCEmployee> getWorkers() {
    return this.workers;
  }
  
  public RCServiceRecord setWorkers(final Iterable<RCEmployee> workers) {
    removeAllWorkers();
    for(RCEmployee ca : workers){
    	addtoWorkers(ca);
    }
    return this;		
    
  }
  
  public RCServiceRecord addtoWorkers(final RCEmployee rCEmployee) {
    this.workers.add(rCEmployee);
    return this;
    
  }
  
  public RCServiceRecord removeAllWorkers() {
    this.workers.clear();
    return this;	
    
  }
  
  public RCServiceRecord removeFromWorkers(final RCEmployee rCEmployee) {
    this.workers.remove(rCEmployee);
    return this;
    
  }
  
  private String workersPhone;
  
  public String getWorkersPhone() {
    return this.workersPhone;
  }
  
  public RCServiceRecord setWorkersPhone(final String workersPhone) {
    this.workersPhone = workersPhone;
    return this;			
    
  }
  
  @JoinColumn(name = "project_id")
  @ManyToOne(targetEntity = RCServiceContractDelegateImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCServiceContractDelegate project;
  
  public RCServiceContractDelegate getProject() {
    return this.project;
  }
  
  public RCServiceRecord setProject(final RCServiceContractDelegate project) {
    this.project = project;
    return this;			
    
  }
  
  @JoinColumn(name = "product_id")
  @ManyToOne(targetEntity = RCIdentifiablePhysicalProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCIdentifiablePhysicalProductEntry product;
  
  public RCIdentifiablePhysicalProductEntry getProduct() {
    return this.product;
  }
  
  public RCServiceRecord setProduct(final RCIdentifiablePhysicalProductEntry product) {
    this.product = product;
    return this;			
    
  }
  
  private Date arriveDate;
  
  public Date getArriveDate() {
    return this.arriveDate;
  }
  
  public RCServiceRecord setArriveDate(final Date arriveDate) {
    this.arriveDate = arriveDate;
    return this;			
    
  }
  
  private Date arriveTime;
  
  public Date getArriveTime() {
    return this.arriveTime;
  }
  
  public RCServiceRecord setArriveTime(final Date arriveTime) {
    this.arriveTime = arriveTime;
    return this;			
    
  }
  
  private Date leaveDate;
  
  public Date getLeaveDate() {
    return this.leaveDate;
  }
  
  public RCServiceRecord setLeaveDate(final Date leaveDate) {
    this.leaveDate = leaveDate;
    return this;			
    
  }
  
  private Date leaveTime;
  
  public Date getLeaveTime() {
    return this.leaveTime;
  }
  
  public RCServiceRecord setLeaveTime(final Date leaveTime) {
    this.leaveTime = leaveTime;
    return this;			
    
  }
  
  @ManyToMany(targetEntity = RCFaultReportServiceTypeImpl.class)
  @JoinTable(name = "m2m_rcservicerecord_servicetypes", joinColumns = @JoinColumn(name = "rcservicerecord_id") , inverseJoinColumns = @JoinColumn(name = "rCFaultReportServiceType_inv_id") )
  private Collection<RCFaultReportServiceType> serviceTypes = new java.util.ArrayList<com.shrct.businessprocess.customerservice.RCFaultReportServiceType>();;
  
  public Collection<RCFaultReportServiceType> getServiceTypes() {
    return this.serviceTypes;
  }
  
  public RCServiceRecord setServiceTypes(final Iterable<RCFaultReportServiceType> serviceTypes) {
    removeAllServiceTypes();
    for(RCFaultReportServiceType ca : serviceTypes){
    	addtoServiceTypes(ca);
    }
    return this;		
    
  }
  
  public RCServiceRecord addtoServiceTypes(final RCFaultReportServiceType rCFaultReportServiceType) {
    this.serviceTypes.add(rCFaultReportServiceType);
    return this;
    
  }
  
  public RCServiceRecord removeAllServiceTypes() {
    this.serviceTypes.clear();
    return this;	
    
  }
  
  public RCServiceRecord removeFromServiceTypes(final RCFaultReportServiceType rCFaultReportServiceType) {
    this.serviceTypes.remove(rCFaultReportServiceType);
    return this;
    
  }
  
  private String serviceTypeComment;
  
  public String getServiceTypeComment() {
    return this.serviceTypeComment;
  }
  
  public RCServiceRecord setServiceTypeComment(final String serviceTypeComment) {
    this.serviceTypeComment = serviceTypeComment;
    return this;			
    
  }
  
  @ManyToMany(targetEntity = RCFaultReportFaultTypeImpl.class)
  @JoinTable(name = "m2m_rcservicerecord_faulttypes", joinColumns = @JoinColumn(name = "rcservicerecord_id") , inverseJoinColumns = @JoinColumn(name = "rCFaultReportFaultType_inv_id") )
  private Collection<RCFaultReportFaultType> faultTypes = new java.util.ArrayList<com.shrct.businessprocess.customerservice.RCFaultReportFaultType>();;
  
  public Collection<RCFaultReportFaultType> getFaultTypes() {
    return this.faultTypes;
  }
  
  public RCServiceRecord setFaultTypes(final Iterable<RCFaultReportFaultType> faultTypes) {
    removeAllFaultTypes();
    for(RCFaultReportFaultType ca : faultTypes){
    	addtoFaultTypes(ca);
    }
    return this;		
    
  }
  
  public RCServiceRecord addtoFaultTypes(final RCFaultReportFaultType rCFaultReportFaultType) {
    this.faultTypes.add(rCFaultReportFaultType);
    return this;
    
  }
  
  public RCServiceRecord removeAllFaultTypes() {
    this.faultTypes.clear();
    return this;	
    
  }
  
  public RCServiceRecord removeFromFaultTypes(final RCFaultReportFaultType rCFaultReportFaultType) {
    this.faultTypes.remove(rCFaultReportFaultType);
    return this;
    
  }
  
  private String faultTypeComment;
  
  public String getFaultTypeComment() {
    return this.faultTypeComment;
  }
  
  public RCServiceRecord setFaultTypeComment(final String faultTypeComment) {
    this.faultTypeComment = faultTypeComment;
    return this;			
    
  }
  
  @ManyToMany(targetEntity = RCFaultReportServiceSummaryImpl.class)
  @JoinTable(name = "m2m_rcservicerecord_faultsummarys", joinColumns = @JoinColumn(name = "rcservicerecord_id") , inverseJoinColumns = @JoinColumn(name = "rCFaultReportServiceSummary_inv_id") )
  private Collection<RCFaultReportServiceSummary> faultSummarys = new java.util.ArrayList<com.shrct.businessprocess.customerservice.RCFaultReportServiceSummary>();;
  
  public Collection<RCFaultReportServiceSummary> getFaultSummarys() {
    return this.faultSummarys;
  }
  
  public RCServiceRecord setFaultSummarys(final Iterable<RCFaultReportServiceSummary> faultSummarys) {
    removeAllFaultSummarys();
    for(RCFaultReportServiceSummary ca : faultSummarys){
    	addtoFaultSummarys(ca);
    }
    return this;		
    
  }
  
  public RCServiceRecord addtoFaultSummarys(final RCFaultReportServiceSummary rCFaultReportServiceSummary) {
    this.faultSummarys.add(rCFaultReportServiceSummary);
    return this;
    
  }
  
  public RCServiceRecord removeAllFaultSummarys() {
    this.faultSummarys.clear();
    return this;	
    
  }
  
  public RCServiceRecord removeFromFaultSummarys(final RCFaultReportServiceSummary rCFaultReportServiceSummary) {
    this.faultSummarys.remove(rCFaultReportServiceSummary);
    return this;
    
  }
  
  private RCServiceStatus status;
  
  public RCServiceStatus getStatus() {
    return this.status;
  }
  
  public RCServiceRecord setStatus(final RCServiceStatus status) {
    this.status = status;
    return this;			
    
  }
  
  private String recommend;
  
  public String getRecommend() {
    return this.recommend;
  }
  
  public RCServiceRecord setRecommend(final String recommend) {
    this.recommend = recommend;
    return this;			
    
  }
  
  private Integer evaluation;
  
  public Integer getEvaluation() {
    return this.evaluation;
  }
  
  public RCServiceRecord setEvaluation(final Integer evaluation) {
    this.evaluation = evaluation;
    return this;			
    
  }
  
  public static RCServiceRecord create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.customerservice.RCServiceRecord rCServiceRecord = new com.shrct.businessprocess.customerservice.impl.RCServiceRecordImpl(
    );
    objectFactory.create(rCServiceRecord);
    return rCServiceRecord;			
    
  }
  
  public static RCServiceRecord createRCServiceRecordImpl(final IObjectFactory objectFactory, final Procedure1<RCServiceRecord> init) {
    com.shrct.businessprocess.customerservice.RCServiceRecord rCServiceRecord = new com.shrct.businessprocess.customerservice.impl.RCServiceRecordImpl(
    );
    objectFactory.create(rCServiceRecord);
    init.apply(rCServiceRecord);
    
    return rCServiceRecord;			
    
  }
  
  public RCServiceRecordProxy toProxy() {
    com.shrct.businessprocess.customerservice.proxy.RCServiceRecordProxy proxy = new com.shrct.businessprocess.customerservice.proxy.RCServiceRecordProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
